'''实验3 列表字典性能测试和栈'''
'''设计一个实验来验证列表索引操作符是 o (1)'''
# from timeit import Timer
# import random
#
# for i in range(10000,1000001,20000):
#     t = Timer("x[random.randrange(%d)]"%i,"from __main__ import random,x")
#
#     x=list(range(i))
#
#     print("%10.4f"%t.timeit(number=1000))
'''设计一个实验来验证字典 的取值操作和赋值操作为 o (1)'''
# import timeit
# import random
#
# for i in range(10000,1000001,20000):
#     t = timeit.Timer("x.get(random.randrange(%d))"%i,"from __main__ import random,x")
#
#
#     x={j:j+1 for j in range(i)}
#
#     d_time = t.timeit(number=1000)
#
#     print("%d,%10.4f "%(i,d_time))

'''20. 有效的括号'''
# class Solution(object):
#     def __init__(self):
#         pass
#     def isValid(self, s:str) -> bool:
#         if len(s) % 2 == 1:
#             return False
#
#         pairs = {
#             ")": "(",
#             "]": "[",
#             "}": "{",
#         }
#         stack = list()
#         for ch in s:
#             if ch in pairs:
#                 if not stack or stack[-1] != pairs[ch]:
#                     return False
#                 stack.pop()
#             else:
#                 stack.append(ch)
#
#         return not stack
#
# def main():
#     s=Solution()
#     print(s.isValid("()"))
#
# if __name__ == '__main__':
#     main()


''''''
# class Solution(object):
#     def check(self,lt,rt):
#         s1='([{'
#         s2=')]}'
#         return s1.index(lt)==s2.index(rt)
#     def isValid(self,word:str)->bool:
#